
/*
需求说明:
电脑运行实例  基于主板运行
接口的多态性,提高了程序的扩展性
*/

class ClassDuoTai  {

	public static void main(String[] args) {
		MainBoard m = new MainBoard();
		m.run();
		m.userPCI(new SoundCard());
		m.userPCI(new NetCard());
		m.userPCI(new ShowCard());

	}

}

interface PCI{
	public void open();
	public void close();
}
//主板
class MainBoard{

	public void run(){
		System.out.println("MainBoard run");
	}

	public void userPCI(PCI p){
		if (p != null) {
			p.open();
			p.close();
		}
	}
}

//声卡
class SoundCard implements PCI{
	public void open(){
		System.out.println("SoundCard Open");
	}
	public void close(){
		System.out.println("SoundCard Close");
	}
}

//网卡
class NetCard implements PCI{
	public void open(){
		System.out.println("NetCard Open");
	}
	public void close(){
		System.out.println("NetCard Close");
	}
}

//显卡
class ShowCard implements PCI{
	public void open(){
		System.out.println("ShowCard Open");
	}
	public void close(){
		System.out.println("ShowCard Close");
	}
}




